<%@page import="nnweboa.User"%>
<%@page import="nnweboa.Unitls"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<%
	String savelocal = "";
	String path = getServletContext().getRealPath(".");
	if (path.indexOf("function") > 0) {
		savelocal = getServletContext().getRealPath("./nt.xml");
	} else {
		savelocal = getServletContext().getRealPath("../nt.xml");
	}
	String mailbox = request.getParameter("mailbox");
	String password = request.getParameter("password");
	String user = request.getParameter("user");
	String smtp = request.getParameter("smtp");

	if (mailbox.isEmpty() || password.isEmpty() || user.isEmpty()
			|| smtp.isEmpty()) {
		request.getRequestDispatcher("function/ntglobelmail.jsp")
				.forward(request, response);
	} else {
		try {
			Unitls.testMail(mailbox, user, password, smtp);
			Unitls.SaveMailSetting(mailbox, user, password, smtp,
					savelocal);
			request.getRequestDispatcher(
					Unitls.getCurrentUserFirstPage(getServletContext()
							.getRealPath("."), User.NTManager, Unitls
							.getCookieName(request))).forward(request,
					response);
		} catch (Exception ex) {
			request.getRequestDispatcher("function/ntglobelmail.jsp")
					.forward(request, response);
		}

	}
%>
</html>